package test;

import com.alibaba.fastjson2.util.DateUtils;
import io.github.loserYa.log.handler.ShardingHandler;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class UserLoginLogShardingHandler implements ShardingHandler<Date> {

    @Override
    public String table() {
        return "log_user_login";
    }

    @Override
    public String column() {
        return "update_date";
    }

    @Override
    public String getPhysicalTable(String logicalTable, Date value) {
        return logicalTable + "_" + DateUtils.format(value, "yyyy_MM");
    }

}
